Skip to content

Method: setExpressionToQuery(StringBuilder, CriteriaParameterFiller)

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.query.criteria;
16:
17: import cz.cvut.kbss.jopa.model.query.criteria.Expression;
18: import cz.cvut.kbss.jopa.model.query.criteria.Predicate;
19: import cz.cvut.kbss.jopa.query.criteria.expressions.AbstractExpression;
20: import cz.cvut.kbss.jopa.sessions.CriteriaBuilder;
21: import java.util.Collections;
22: import java.util.List;
23:
24: public class SimplePredicateImpl extends AbstractPredicate{
25:
26: protected Expression<Boolean> expression;
27:
28: public SimplePredicateImpl(BooleanOperator booleanOperator, Expression<Boolean> expression, CriteriaBuilder cb) {
29: super(booleanOperator, cb);
30: this.expression = expression;
31: }
32:
33:
34: public SimplePredicateImpl(Expression<Boolean> expression, CriteriaBuilder cb) {
35: super(BooleanOperator.AND, cb);
36: this.expression = expression;
37: }
38:
39: @Override
40: public List<Expression<Boolean>> getExpressions(){
41: return Collections.emptyList();
42: }
43:
44: @Override
45: public BooleanOperator getOperator() {
46: return this.booleanOperator;
47: }
48:
49: @Override
50: public Predicate not() {
51: ((AbstractExpression)expression).negate();
52: super.negate();
53: return this;
54: }
55:
56: @Override
57: public void setExpressionToQuery(StringBuilder query, CriteriaParameterFiller parameterFiller) {
58: AbstractExpression abstractExpression = (AbstractExpression) expression;
59: abstractExpression.setExpressionToQuery(query, parameterFiller);
60: }
61:
62: @Override
63: public void negate(){
64: this.not();
65: }
66: }